#include <iostream>
#include "test/TestCluster.hpp"
int main()
{
    //1. 这里测试一系列数据,让type一致,且x距离小于2的聚类在一起
    cluster::vecData_t vecData;
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,0.5));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,0.6));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,1.1));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,10.5));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,10.2));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,100.6));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,110.4));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(0,111.2));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,0.5));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,0.6));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,1.1));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,10.5));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,10.2));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,100.6));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,110.4));
    vecData.emplace_back(std::make_shared<cluster::Data_t>(1,111.2));

    //2. 组装对象
    cluster::vecClusterObject_t vecObject;
    vecObject.reserve(vecData.size());
    for (auto &ptr : vecData)
    {
        auto obj = std::make_shared<cluster::ClusterObject_t>(ptr.get());
        obj->x   = ptr->x;
        vecObject.push_back(obj);
    }

    //3. 使用遍历聚类
    cluster::TestCluster cluster1;
    auto res1 = cluster1.cluster(vecObject);
    std::cout << "遍历聚类----------\n";
    cluster::print(res1);

    //3. 使用网格聚类
    cluster::TestCluster2D cluster2;
    auto res2 = cluster2.clusterFor2D(vecObject, cluster::ConstDist);
    std::cout << "网格聚类----------\n";
    cluster::print(res2);
    return 0;
}